package main

import (
	"fmt"
	"time"
)

/**
使用 defer 追踪执行时间
 */
func main() {
	fmt.Println("执行开始")
	defer TrackTime(time.Now())
	time.Sleep(1500 * time.Millisecond)
	fmt.Println("执行结束")
}

func TrackTime(pre time.Time)  {
	elapsed := time.Since(pre)
	fmt.Println("用时:", elapsed)
}